package org.apache.dubbo.demo.consumer.example.eg13;

import java.util.concurrent.CompletableFuture;
import org.apache.dubbo.demo.example.eg13.AsyncService;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Application {

  public static void main(String[] args) {
    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:example/eg13/applicationContext.xml");
    AsyncService asyncService = (AsyncService) context.getBean("asyncService");
    CompletableFuture<String> future = asyncService.sayHello("xufeng");
    future.whenComplete((r, t) -> {
      if (t != null) {
        t.printStackTrace();
      } else {
        System.out.println("********************* result: " + r + " *********************");
      }
    });

    System.out.println("********************* executed before response *********************");
  }

}
